home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / C⁄C++ OS8 / LayerGroups / EditFields.cp < prev    next >
Encoding:
Text File  |  1998-10-23  |  3.2 KB  |  135 lines  |  [TEXT/CWIE]

  1. // EditFields.cp -- Modal dialog
  2.  
  3. #include <Types.h>
  4. #include <Quickdraw.h>
  5. #include <Controls.h>
  6. #include <Dialogs.h>
  7. #include <Events.h>
  8. #include <Lists.h>
  9. #include <Menus.h>
  10. #include <TextEdit.h>
  11. #include <Appearance.h>
  12.  
  13. #include "ResourceDefs.h"
  14. #include "Miscellany.h"
  15. #include "ControlUtils.h"
  16.  
  17. #include "EditFields.h"
  18.  
  19. #define kOKButton        1
  20. #define kCancelButton        2
  21. #define kThePictureAndCaptionAreInLabel        3
  22. #define kFullLengthLabel        4
  23. #define kFBFullLengthField        5
  24. #define kBodyWidthLabel        6
  25. #define kFBBodyWidthField        7
  26. #define kShoulderSlopeLabel        8
  27. #define kFBShSlopeField        9
  28. #define kPictureAndTextGroup        10
  29. #define kFullLength2Layer        11
  30. #define kFullLengthPictImage        12
  31. #define kFromHighShoulderOverBustTLabel        13
  32. #define kBodyWidth2Layer        14
  33. #define kBodyWidthPictImage        15
  34. #define kSideSeamToSideSeam12InchBLabel        16
  35. #define kShoulderSlope2Layer        17
  36. #define kShoulderSlopePictImage        18
  37. #define kShoulderEdgeOverBustToCenLabel        19
  38.  
  39.  
  40. //----------
  41. // static
  42. Boolean        CEditFields::GetEditFields (
  43.     DEditFieldsData*        ioData)
  44. {
  45.     Boolean            result = false;
  46.     CEditFields*        dialog = new CEditFields;
  47.  
  48.     result = dialog->RunModal (DLOG_EditFields, ioData);
  49.  
  50.     delete dialog;
  51.  
  52.     return result;
  53. }
  54.  
  55. //----------
  56. CEditFields::CEditFields ()
  57. {
  58.     mData = nil;
  59. }
  60.  
  61. //----------
  62. CEditFields::~CEditFields ()
  63. {
  64. }
  65.  
  66. //----------
  67. void    CEditFields::FinishMake ()
  68. {
  69.     mOKHandle = GetControlItem (kOKButton);
  70.     SetDefaultState (mOKHandle, true);
  71.     ::SetDialogDefaultItem (mDialog, kOKButton);
  72.     mCancelHandle = GetControlItem (kCancelButton);
  73.     ::SetDialogCancelItem (mDialog, kCancelButton);
  74.     mFBFullLengthHandle = GetControlItem (kFBFullLengthField);
  75.     mFBBodyWidthHandle = GetControlItem (kFBBodyWidthField);
  76.     mFBShSlopeHandle = GetControlItem (kFBShSlopeField);
  77.     mPictureAndTextHandle = GetControlItem (kPictureAndTextGroup);
  78. }
  79.  
  80. //----------
  81. void    CEditFields::ConnectToData (
  82.     AMSignaler*        inData)
  83. {
  84.     AMDialog::ConnectToData (inData);
  85.     mData = (DEditFieldsData*) inData;
  86.  
  87.     SetControlTextFloat (mFBFullLengthHandle, mData->GetFBFullLength ());
  88.     SetControlTextFloat (mFBBodyWidthHandle, mData->GetFBBodyWidth ());
  89.     SetControlTextFloat (mFBShSlopeHandle, mData->GetFBShSlope ());
  90.     SetLayerGroupValue (mPictureAndTextHandle, mData->GetEditingWhat ());
  91. }
  92.  
  93. //----------
  94. void    CEditFields::DataChanged (
  95.     long        inDataID)
  96. {
  97.     if (inDataID == idFBFullLength) {
  98.         SetControlTextFloat (mFBFullLengthHandle, mData->GetFBFullLength ());
  99.     }
  100.     if (inDataID == idFBBodyWidth) {
  101.         SetControlTextFloat (mFBBodyWidthHandle, mData->GetFBBodyWidth ());
  102.     }
  103.     if (inDataID == idFBShSlope) {
  104.         SetControlTextFloat (mFBShSlopeHandle, mData->GetFBShSlope ());
  105.     }
  106.     if (inDataID == idEditingWhat) {
  107.         SetLayerGroupValue (mPictureAndTextHandle, mData->GetEditingWhat ());
  108.     }
  109. }
  110.  
  111.  
  112. //----------
  113. void    CEditFields::DoItem (
  114.     SInt16        inItemHit)
  115. {
  116.     switch (inItemHit) {
  117.     case kOKButton:
  118.             SetResult (true);
  119.         break;
  120.     case kCancelButton:
  121.             SetResult (false);
  122.         break;
  123.     case kFBFullLengthField:
  124.             mData->SetFBFullLength (GetControlTextFloat (mFBFullLengthHandle));
  125.         break;
  126.     case kFBBodyWidthField:
  127.             mData->SetFBBodyWidth (GetControlTextFloat (mFBBodyWidthHandle));
  128.         break;
  129.     case kFBShSlopeField:
  130.             mData->SetFBShSlope (GetControlTextFloat (mFBShSlopeHandle));
  131.         break;
  132.  
  133.     } // switch
  134. }
  135.